package cn.c3n.demo.controller;

import cn.c3n.demo.properties.GirlProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
public class HelloController {

    @Value("${sex}")
    private String sex;

    @Value("${age}")
    private Integer age;

    @Value("${content}")
    private String content;

    @Autowired
    private GirlProperties girlProperties;


    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String say() {
        return "Hello Spring boot..." + age + sex + content+ girlProperties.getContent();
    }

    @RequestMapping(value ={"hi/{id}", "hehe"}, method = RequestMethod.GET)
    public String hi(@PathVariable("id") Integer myId){
        return "id:"+ myId;
    }

    @RequestMapping(value ={"hi2", "hehe2"}, method = RequestMethod.GET)
    public String hi2(@RequestParam("id") Integer myId){
        return "id:"+ myId;
    }

    @RequestMapping(value ={"hi3", "hehe3"}, method = RequestMethod.GET)
    public String hi3(@RequestParam(value = "id", required = false, defaultValue = "0") Integer myId){
        return "id:"+ myId;
    }
}
